﻿using HPIT.RentHouse.Common;
using HPIT.RentHouse.DTO;
using HPIT.RentHouse.IService;
using HPIT.RentHouse.Service.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HPIT.RentHouse.Service
{
    public class CityService : ICityService
    {
        public AjaxResult Delete(long id)
        {
            var db = new RentHouseEntities();
            BaseService<T_AdminUsers> bs = new BaseService<T_AdminUsers>(db);
            var model = bs.Get(e => e.Id == id);
            if (bs.Delete(model))
            {
                return new AjaxResult(ResultState.Success, "删除角色成功");
            }
            else
            {
                return new AjaxResult(ResultState.Error, "删除角色失败");
            }
        }

        public List<CityDTO> GetList()
        {
            RentHouseEntities db = new RentHouseEntities();
            BaseService<T_Cities> baseService = new BaseService<T_Cities>(db);
            List<CityDTO> list= baseService.GetList(p => true).Select(p => new CityDTO
            {
                Id = p.Id,
                Name = p.Name
            }).ToList();
            return list;
        }
    }
}
